<?php /*
	
*/ ?>
<?php include("inc/head.inc.php"); ?>
<?php
if(isset($_REQUEST['act']) && ($_REQUEST['act'])=="addtowish")
{
	if(!isset($_SESSION['memberid'])) {
			/*echo "<script language=\"JavaScript\" type=\"text/javascript\">setTimeout(location:'customerlogin.php', 0);</script>";*/	
			echo "<meta http-equiv='Refresh' content='0; URL=customerlogin.php'>";
	} elseif (isset($_REQUEST['product']) && ($_REQUEST['product'])!="") {
		$proid=mysql_real_escape_string($_REQUEST['product']);
		if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")	{
			$memid=$_SESSION['memberid'];
		}
		$sqlwish="SELECT * FROM `tblwishlist` WHERE intmemid='$memid' AND intproductid='$proid'";
		$reswish=$n02586916_db->select($sqlwish);
		if(count($reswish)>0) {
			$errmsg = $mess['pralready'];
		}  else {
				$insert="INSERT INTO `tblwishlist`(`intmemid`,`intproductid`) VALUES ('$memid','$proid')";
				$sqlins=$n02586916_db->insert($insert);
		}
	}
}

if(isset($_REQUEST['a']) && ($_REQUEST['a'])==3)
{
	if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!="")
	{
		$proid=$_REQUEST['proid'];
		$sqldel="delete from tblwishlist where intproductid='$proid'";
		$del=mysql_query($sqldel);
			/*echo "<script language=\"JavaScript\" type=\"text/javascript\">setTimeout(\"location:'mywishlist.php?msg=delprfwl&memid=".$memid."'\", 0);</script>";*/
			//echo "<meta http-equiv='Refresh' content='0; URL=mywishlist.php?msg=delprfwl&memid=".$memid."'>";
			$errmsg = $mess['delprfwl'];
	}
}

if(isset($_REQUEST['Submit']) && ($_REQUEST['Submit'])=='Send') {
		if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")	{
			$memid=$_SESSION['memberid'];
			$sqlmem="select `varcustemail`,`varcustfname` from tblcustomers where intcusid='$memid'";
			$resmem=$n02586916_db->select($sqlmem);
				if($resmem)	{
					$memberemail=$resmem[0]['varcustemail'];
					$memfirstname=$resmem[0]['varcustfname']; 
				}
		}
		$email=$_REQUEST['frndemail'];
		$to=$email;
		$url=WEBSITEURL.$_SERVER['PHP_SELF']."?memid=".$memid;
		$frdname=$_REQUEST['frndname'];
		$sqlemail="select `txtmesswish`,`varsubwish` from `tblemails`";
		$resemail=$n02586916_db->select($sqlemail);
		if($resemail){
			$wisub=$resemail[0]['varsubwish'];
			$wimess=$resemail[0]['txtmesswish'];
		}
		$msg_subject=$wisub;
		$message="Hello,
		".$frdname."
		".$wimess."
		".$url."
		
		Thank you
		
		".$memfirstname."
		";
		$header="From:".$memberemail;
		mail($to,$msg_subject,$message,$header);
		$errmsg = $mess['messent'];
}
?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
    <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td valign="top"class="leftmenuback"><?php include(INC."left.inc.php") ?></td>
        <td valign="top">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="25" colspan="2" valign="middle" class="head">
            <div class="pageheader">My Wishlist</div></td>
        </tr>
		<tr>
          <td colspan="2" valign="middle" align="center"><span class="msg"><?php if(isset($errmsg)) { echo $errmsg; }?></span></td>
        </tr>
		<?php 
			if(isset($_REQUEST['memid']) && ($_REQUEST['memid'])!="") {
				$memid=mysql_real_escape_string($_REQUEST['memid']);
			} else if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="") {
				$memid=$_SESSION['memberid'];
			} else {
				$memid=$memid;
			}
			$sqlwish="select * from tblwishlist where intmemid='$memid'";
			$resgid=$n02586916_db->select($sqlwish);
			if(count($resgid)>0)
			{
				for($p=0;$p<count($resgid);$p++)
				{
					$prid=$resgid[$p]['intproductid'];
					 $sql6="select * from tblproddesc where intid='$prid'";
					 $resprname1=$n02586916_db->select($sql6);
					 if(count($resprname1)>0) {
						$desc=$resprname1[0]['txtdesc'];
						$resprname1=$resprname1[0]['varprodname'];
					 } else {
						$resprname1="";
					 }
					  $sql6="select * from tblproducts where intprodid='$prid'";
					  $resprname=$n02586916_db->select($sql6);
					  if(count($resprname)>0) {
					  $proprice=$resprname[0]['decprice'];
					
					if (file_exists("images/product/midium/".$resprname[0]['intproddefaultimg'])) {
						$image = "images/product/midium/".$resprname[0]['intproddefaultimg'];
					} else {
						$image = "images/product/noimage.jpg";
					}
		?>
        <tr>
          <td width="50%"><table width="268" height="188" border="0" cellpadding="0" cellspacing="2" class="prborderbg">
            <tr>
              <td width="91" rowspan="2" align="center"><img src="<?php echo $image;?>" border="0" /></td>
              <td width="165" height="20" class="search">&nbsp;<strong>
                <?php echo $resprname1;?>
              </strong></td>
            </tr>
            <tr>
              <td height="40" class="price">$
                <?php echo $proprice;?></td>
            </tr>
            <tr>
              <td align="center"><?php
			  if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")
				{
			  ?>
                <a href="mywishlist.php?a=3&amp;proid=<?php echo $prid;?>" class="aa" onClick="return confirm('Are you sure want to delete?');">[Remove]</a>
                <?php }?></td>
              <td><a href="proddetail.php?proid=<?php echo $prid;?>"><img src="images/buynow.jpg" border="0" /></a></td>
            </tr>
            <tr>
              <td colspan="2" valign="top" class="font"><?php
				if(strlen($desc) > 100 ) {
				$desc=substr($desc,0,100); 
				$desc=$desc."...";
				//echo $desctxt;
				}
				echo srchwordchangestyl($desc);
			  ?></td>
            </tr>
          </table></td>
		  <?php 
		  	$p++;
			if(isset($resgid[$p]))
			{
			 $id=$resgid[$p]['intproductid'];
			 $sql6="select * from tblproddesc where intid='$id'";
			  $resprname1=$n02586916_db->select($sql6);
			 if(count($resprname1)>0)
			 {
			 	$desc=$resprname1[0]['txtdesc'];
			 	$resprname1=$resprname1[0]['varprodname'];
			 }
			 else
			 {
			 	$resprname1="";
			 }
			
			  $sql6="select * from tblproducts where intprodid='$id'";
			 
			  $resprname=$n02586916_db->select($sql6);
			  if(count($resprname)>0)
			  {
			   $proprice=$resprname[0]['decprice'];
			  		 if (file_exists("images/product/midium/".$resprname[0]['intproddefaultimg'])) {
						$image = "images/product/midium/".$resprname[0]['intproddefaultimg'];
					} else {
						$image = "images/product/noimage.jpg";
					}
		  ?>
          <td width="50%"><table width="268" height="188" border="0" cellpadding="0" cellspacing="2" class="prborderbg">
            <tr>
              <td width="91" rowspan="2" align="center"><img src="<?php echo $image;?>"  border="0"/></td>
              <td height="20" class="search">&nbsp;<strong>
                <?php echo $resprname1;?>
              </strong></td>
            </tr>
            <tr>
              <td height="40" class="price">$
                <?php echo $proprice;?></td>
            </tr>
            <tr>
              <td align="center"><?php 
			  if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")
				{
			  ?>
                <a href="mywishlist.php?a=3&amp;proid=<?php echo $id;?>" class="aa" onClick="return confirm('Are you sure want to delete?');">[Remove]</a>
                <?php }?></td>
              <td><a href="proddetail.php?proid=<?php echo $id;?>"><img src="images/buynow.jpg" border="0" /></a></td>
            </tr>
            <tr>
              <td colspan="2" valign="top" class="font"><?php
				if(strlen($desc) > 45 )
				{
				$desc=substr($desc,0,45); 
				$desc=$desc."...";
				}
				echo srchwordchangestyl($desc);
			  ?></td>
            </tr>
          </table></td>
        </tr> <?php 
		}}}}}
			?>
			<tr>
			<td colspan="2"><form action="" method="post" name="wishtofrd" id="wishtofrd">
              <?php if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")	{ ?>
              <br />
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="22" colspan="4"><table width="98%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="22" class="search">&nbsp;&nbsp;Send to your Friend </td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td class="font">&nbsp;</td>
                  <td class="font">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td width="7%" align="center" class="font">&nbsp;</td>
                  <td width="28%" align="left" class="font">Friend's E-Mail Address </td>
                  <td width="1%" align="left" class="font">:</td>
                  <td width="64%" align="left"><input name="frndemail" type="text" class="font" id="frndemail" /></td>
                </tr>
                <tr>
                  <td colspan="4" align="center" class="font" height="3"></td>
                </tr>
                <tr>
                  <td align="center" class="font">&nbsp;</td>
                  <td align="left" class="font">Friend's Name </td>
                  <td align="left" class="font">:</td>
                  <td align="left"><input name="frndname" type="text" class="font" id="frndname" /></td>
                </tr>
                <tr>
                  <td colspan="4" align="center">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="4" align="center"><input name="Submit" type="submit" class="feature_headingbg" value="Send" /></td>
                </tr>
              </table>
			  <?php }?>
            </form></td>
			</tr>
      </table>		</td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>
